﻿using System;
using System.Windows;
using System.Windows.Controls;

namespace FileManager
{
	public partial class FileObject : UserControl
	{
        #region Variables
        private string _FullFileName;
        private string _ShortFileName;
        private string _LocalFileNameAndPath;
        private int _FileID;
        private bool _SeletedFile;
        private bool _IsLocal;

        public string FullFileName
        {
            get { return _FullFileName; }
            set { _FullFileName = value; }
        }

        public string ShortFileName
        {
            get { return _ShortFileName; }
            set { _ShortFileName = value; }
        }

        public string LocalFileNameAndPath
        {
            get { return _LocalFileNameAndPath; }
            set { _LocalFileNameAndPath = value; }
        } 
        
        public int FileID
        {
            get { return _FileID; }
            set { _FileID = value; }
        }

        public bool SeletedFile
        {
            get { return _SeletedFile; }
            set { _SeletedFile = value; }
        }

        public bool IsLocal
        {
            get { return _IsLocal; }
            set { _IsLocal = value; }
        }
        #endregion

		public FileObject(string strFileName, bool boolisLocal)
		{
			// Required to initialize variables
			InitializeComponent();
            this.FileObjectFileName.Text = strFileName;
            this.FileObjectFileName.FontSize = Convert.ToDouble(9.5);

            _IsLocal = boolisLocal;

            if (!_IsLocal)
            {
                ToolTipService.SetToolTip(DownloadIcon, "Download");
            }
		}

        #region UserControl_MouseEnter
        private void UserControl_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
        {
            // Set the current FileObject To Hover
            VisualStateManager.GoToState(this, "Hover", true);

            // Set the Name
            this.FileObjectFileName.Text = _FullFileName;

            if (_FullFileName.Length > 18)
            {
                this.FileObjectFileName.FontSize = Convert.ToDouble(7);
            }
        } 
        #endregion

        #region UserControl_MouseLeave
        private void UserControl_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
        {
            // If this is not the selected file then remove the Hover
            if (!SeletedFile)
            {
                VisualStateManager.GoToState(this, "NoHover", true);
            }

            // If this is the selected file then change state to unHover
            if (SeletedFile)
            {
                VisualStateManager.GoToState(this, "UnHover", true);
            }

            this.FileObjectFileName.Text = _ShortFileName;
            this.FileObjectFileName.FontSize = Convert.ToDouble(9.5);
        } 
        #endregion

        // GoToState

        #region GoToStateHover
        public void GoToStateHover()
        {
            VisualStateManager.GoToState(this, "Hover", true);
        } 
        #endregion

        #region GoToStateNoHover
        public void GoToStateNoHover()
        {
            VisualStateManager.GoToState(this, "NoHover", true);
        } 
        #endregion

        #region GoToStateToUnHover
        public void GoToStateToUnHover()
        {
            VisualStateManager.GoToState(this, "UnHover", true);
        } 
        #endregion
	}
}